load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")

proto_library(
    name = "enginepb_proto",
    srcs = [
        "engine.proto",
        "file_registry.proto",
        "mvcc.proto",
        "mvcc3.proto",
        "rocksdb.proto",
    ],
    strip_import_prefix = "/pkg",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/kv/kvserver/concurrency/isolation:isolation_proto",
        "//pkg/util/hlc:hlc_proto",
        "@com_github_gogo_protobuf//gogoproto:gogo_proto",
    ],
)

go_proto_library(
    name = "enginepb_go_proto",
    compilers = ["//pkg/cmd/protoc-gen-gogoroach:protoc-gen-gogoroach_compiler"],
    importpath = "github.com/cockroachdb/cockroach/pkg/storage/enginepb",
    proto = ":enginepb_proto",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/kv/kvserver/concurrency/isolation",
        "//pkg/util/hlc",
        "//pkg/util/uuid",  # keep
        "@com_github_gogo_protobuf//gogoproto",
    ],
)

go_library(
    name = "enginepb",
    srcs = [
        "decode.go",
        "engine.go",
        "file_registry.go",
        "mvcc.go",
        "mvcc3.go",
        "mvcc3_valueheader.go",
    ],
    embed = [":enginepb_go_proto"],
    importpath = "github.com/cockroachdb/cockroach/pkg/storage/enginepb",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/kv/kvnemesis/kvnemesisutil",
        "//pkg/util/buildutil",
        "//pkg/util/hlc",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_cockroachdb_redact//:redact",
    ],
)

go_test(
    name = "enginepb_test",
    size = "small",
    srcs = [
        "decode_test.go",
        "mvcc3_test.go",
        "mvcc_test.go",
    ],
    embed = [":enginepb"],
    deps = [
        "//pkg/kv/kvserver/concurrency/isolation",
        "//pkg/roachpb",
        "//pkg/storage",
        "//pkg/testutils/zerofields",
        "//pkg/util/hlc",
        "//pkg/util/protoutil",
        "//pkg/util/uuid",
        "@com_github_cockroachdb_redact//:redact",
        "@com_github_stretchr_testify//assert",
        "@com_github_stretchr_testify//require",
    ],
)
